<?php


namespace App\Internals;


use FoxLib\Exceptions\InternalServiceException;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;

class UserInternal
{
    public static function getByUserId($userId)
    {
        try {
            $client = new Client();
            $rpcUrl = config('app.internal_services_host.user') . "/internal/users/{$userId}" ;
            $response = $client->request('GET', $rpcUrl);
            $result = json_decode($response->getBody(), true);
            return $result['data'];
        } catch (ClientException $e) {
            throw new InternalServiceException();
        }
    }
}